﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Mimoza.Plugins.DisplaySettings
{
 
    public partial class AdvancedSettingsForm : Form
    {
        private List<int> m_listOfFreq;
        private List<ColorDepth> m_listOfColor;
        private int m_currentFreq;
        private ColorDepth m_currentColor;

        public class DisplayFreq
        {
            public int freq;

            public DisplayFreq(int f)
            {
                freq = f;
            }
            public string DisplayText
            {
                get
                {
                    return freq.ToString() + " Hertz";
                }
            }
        }
        public class DisplayColorDepth
        {
            public ColorDepth color;

            public DisplayColorDepth(ColorDepth _color)
            {
                color = _color;
            }
            public string DisplayText
            {
                get
                {
                    switch (color)
                    { 
                        case ColorDepth.Color8Bit:
                            return "256 Color (8 bit)";
                        case ColorDepth.Color16Bit:
                            return "High Color (16 bit)";
                        case ColorDepth.Color24Bit:
                            return "True Color (24 bit)";
                        case ColorDepth.Color32Bit:
                            return "True Color (32 bit)";
                        default:
                            return "worng color";
                    }
                    
                }
            }
        }

        public List<int> ListOfFreq
        {
            get
            {
                return m_listOfFreq;
            }
            set
            {
                m_listOfFreq = value;
                this.comboBoxFreq.DisplayMember = "DisplayText";
                this.comboBoxFreq.Items.Clear();
                foreach (int freq in m_listOfFreq)
                {
                    this.comboBoxFreq.Items.Add(new DisplayFreq(freq));
                }

            }
        }
        public List<ColorDepth> ListOfColor
        {
            get
            {
                return m_listOfColor;
            }
            set
            {
                m_listOfColor = value;
                this.comboBoxColors.DisplayMember = "DisplayText";
                this.comboBoxColors.Items.Clear();
                foreach (ColorDepth color in m_listOfColor)
                {
                    this.comboBoxColors.Items.Add(new DisplayColorDepth(color));
                }
            }
        }
        public int CurrentFreq
        {
            get
            {
                return m_currentFreq;
            }
            set
            {
                m_currentFreq = value;
                
                for (int i = 0; i < m_listOfFreq.Count; i++)
                {
                    if (m_listOfFreq[i] == m_currentFreq)
                    {
                        this.comboBoxFreq.SelectedIndex = i;
                        break;
                    }
                }
            }
        }
        public ColorDepth CurrentColor
        {
            get
            {
                return m_currentColor;
            }
            set
            {
                m_currentColor = value;
                for (int i = 0; i < m_listOfColor.Count; i++)
                {
                    if (m_listOfColor[i] == m_currentColor)
                    {
                        this.comboBoxColors.SelectedIndex = i;
                        break;
                    }
                }
            }
        }

        public AdvancedSettingsForm()
        {
            InitializeComponent();
        }
         
        private void comboBoxFreq_SelectedIndexChanged(object sender, EventArgs e)
        {
            m_currentFreq = (this.comboBoxFreq.SelectedItem as DisplayFreq).freq;
        }
        private void comboBoxColors_SelectedIndexChanged(object sender, EventArgs e)
        {
            m_currentColor = (this.comboBoxColors.SelectedItem as DisplayColorDepth).color;
        }
    }
}
